﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpWeb
{
    /// <summary>
    /// 组件上下文
    /// </summary>
    public sealed class ComponentContext
    {
        public ComponentContext(IComponent component, ModuleContext modulecontext)
        {
            _Component = component;
            _ModuleContext = modulecontext;
        }
        private IComponent _Component;
        /// <summary>
        /// 此上下文关联到的组件
        /// </summary>
        public IComponent Component
        {
            get { return _Component; }
            internal set { _Component = value; }
        }

        private ModuleContext _ModuleContext;

        public ModuleContext ModuleContext
        {
            get { return _ModuleContext; }
        }

        private bool _DesignMode;
        /// <summary>
        /// 组件是否处于设计模式？
        /// </summary>
        public bool DesignMode
        {
            get { return _DesignMode; }
            internal set { _DesignMode = value; }
        }

        public ComponentContext Clone(IComponent component)
        {
            return new ComponentContext(component, this.ModuleContext)
            {
                DesignMode = this.DesignMode
            };
        }

    }
}
